package cn.tedu.review;
/**本类用于回顾面向对象的知识
 * 执行顺序：构造代码块-->构造方法-->普通方法-->局部代码块*/
public class TestOOP {
    public static void main(String[] args) {
        Teacher t1=new Teacher();
        System.out.println("-------------");
        Teacher t2=new Teacher(2);
        System.out.println("-------------");
        Teacher t3=new Teacher("张",'女',999.8,25);
        System.out.println("-------------");
        t3.ready();

    }
}
class Teacher{
    String name;
    char gender;
    double salary;
    int age;

    public Teacher(){
        System.out.println("我是无参构造");//与本类同名，且没有参数列表
    }
    public Teacher(int n){
        System.out.println("我是含参构造："+n);
    }

    public Teacher(String name, char gender, double salary, int age) {
        this.name = name;
        this.gender = gender;
        this.salary = salary;
        this.age = age;
        System.out.println("我是全参构造");
    }

    public void ready(){
        {
            System.out.println("我是局部代码块");
        }
        System.out.println("正在备课...");

    }
    public void teach(){
        System.out.println("正在授课...");
    }
    //4.类里方法外的构造代码块
    {
        System.out.println("我是构造代码块");
    }
}
